<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<script type="text/javascript"
	src="http://developer.baidu.com/map/jsdemo/demo/changeMore.js"></script>
<head>
<title>Welcome to the IMDroid</title>
</head>
<body>
	<f:view>
		<table>
			<tr>
				<td colspan="2">前12天的路线：</td>

			</tr>

		</table>
	</f:view>

	<input type='button' value='开始' onclick='run();' />
	<div style="width: 820px; height: 440px; border: 1px solid gray"
		id="container"></div>
</body>
<script type="text/javascript">
	var locations = new Array();
	<c:forEach var="the" items="${sessionScope.imdroidUser.path}"
		varStatus="i">

	var vpoint = new BMap.Point(<c:out value="${the.pos_lon}" />,
			<c:out value="${the.pos_lat}" />);
	locations[<c:out value="${i.count - 1}" />] = vpoint;
	</c:forEach>

	var map = new BMap.Map("container");

	map.centerAndZoom(locations[0], 16);
	map.addControl(new BMap.NavigationControl());
	map.enableScrollWheelZoom();

	function callback(xyResults) {
		var xyResult = null;
		var lines = new Array();
		var i = 0;

		for ( var index in xyResults) {
			xyResult = xyResults[index];
			if (xyResult.error != 0) {
				continue;
			}
			var point = new BMap.Point(xyResult.x, xyResult.y);
			lines[i] = point;
			++i;
			//var marker = new BMap.Marker(point);
			//map.addOverlay(marker);
			//map.setCenter(point);
		}
		//alert(lines);
		var polyline = new BMap.Polyline(lines, {
			strokeColor : "blue",
			strokeWeight : 6,
			strokeOpacity : 0.5
		});
		map.addOverlay(polyline);
		/*for ( var index in xyResults) {
			xyResult = xyResults[index];
			if (xyResult.error != 0) {
				continue;
			}
			var point = new BMap.Point(xyResult.x, xyResult.y);
			var marker = new BMap.Marker(point);
			map.addOverlay(marker);
			map.setCenter(point);
		}*/
	}
	setTimeout(function() {
		BMap.Convertor.transMore(locations, 0, callback); //一秒之后开始进行坐标转换。参数2，表示是从GCJ-02坐标到百度坐标。参数0，表示是从GPS到百度坐标
	}, 1000);
</script>
</html>